using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication11.Models.Mapping
{
    public class follow_up_drugMap : EntityTypeConfiguration<follow_up_drug>
    {
        public follow_up_drugMap()
        {
            // Primary Key
            this.HasKey(t => t.drug_take_id);

            // Properties
            this.Property(t => t.create_by)
                .HasMaxLength(20);

            this.Property(t => t.update_by)
                .HasMaxLength(20);

            this.Property(t => t.drug_name)
                .IsRequired()
                .HasMaxLength(100);

            this.Property(t => t.dosage)
                .HasMaxLength(50);

            this.Property(t => t.usage)
                .HasMaxLength(80);

            this.Property(t => t.use_reason)
                .HasMaxLength(80);

            this.Property(t => t.drug_type)
                .HasMaxLength(1);

            this.Property(t => t.notice)
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("follow_up_drug");
            this.Property(t => t.drug_take_id).HasColumnName("drug_take_id");
            this.Property(t => t.create_time).HasColumnName("create_time");
            this.Property(t => t.create_by).HasColumnName("create_by");
            this.Property(t => t.update_time).HasColumnName("update_time");
            this.Property(t => t.update_by).HasColumnName("update_by");
            this.Property(t => t.follow_up_id).HasColumnName("follow_up_id");
            this.Property(t => t.drug_name).HasColumnName("drug_name");
            this.Property(t => t.dosage).HasColumnName("dosage");
            this.Property(t => t.usage).HasColumnName("usage");
            this.Property(t => t.use_reason).HasColumnName("use_reason");
            this.Property(t => t.drug_type).HasColumnName("drug_type");
            this.Property(t => t.frequency).HasColumnName("frequency");
            this.Property(t => t.notice).HasColumnName("notice");
            this.Property(t => t.medicine_id).HasColumnName("medicine_id");

            // Relationships
            this.HasOptional(t => t.medicine)
                .WithMany(t => t.follow_up_drug)
                .HasForeignKey(d => d.medicine_id);

        }
    }
}
